package com.jy.adscm.operation.hscrb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.hscrb.bean.YlMaterialinfo;
import com.jy.adscm.operation.hscrb.mapper.mysql.YlMaterialinfoMapper;
import com.jy.adscm.operation.hscrb.service.YlMaterialinfoService;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-12-18
 */
@Service
public class YlMaterialinfoServiceImpl extends ServiceImpl<YlMaterialinfoMapper, YlMaterialinfo> implements YlMaterialinfoService {
  @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<YlMaterialinfo> selectByTid(String tid) {
        Wrapper<YlMaterialinfo> wrapper =new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<YlMaterialinfo> ylMaterialinfos = super.selectList(wrapper);
        for (YlMaterialinfo ylMaterialinfo : ylMaterialinfos) {
            if (ylMaterialinfo.getPerson()!=null && !"".equals(ylMaterialinfo.getPerson())){
                JyUser jyUser = jyUserMapper.selectById(ylMaterialinfo.getPerson());
                ylMaterialinfo.setPersonName(jyUser.getName());
            }
        }
        return ylMaterialinfos;
    }
}
